package com.ruoyi.web.controller.wfshou;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wfshou.domain.Process;
import com.ruoyi.wfshou.service.IProcessService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 加工技术类Controller
 * 
 * @author zongying
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/wfshou/process")
public class ProcessController extends BaseController
{
    @Autowired
    private IProcessService processService;

    /**
     * 查询加工技术类列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:list')")
    @GetMapping("/list")
    public TableDataInfo list(Process process)
    {
        startPage();
        List<Process> list = processService.selectProcessList(process);
        return getDataTable(list);
    }
    @GetMapping("/listAll")
    public TableDataInfo list()
    {
        List<Process> list = processService.selectProcessList(null);
        return getDataTable(list);
    }
    /**
     * 导出加工技术类列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:export')")
    @Log(title = "加工技术类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Process process)
    {
        List<Process> list = processService.selectProcessList(process);
        ExcelUtil<Process> util = new ExcelUtil<Process>(Process.class);
        util.exportExcel(response, list, "加工技术类数据");
    }

    /**
     * 获取加工技术类详细信息
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:query')")
    @GetMapping(value = "/{procId}")
    public AjaxResult getInfo(@PathVariable("procId") Long procId)
    {
        return success(processService.selectProcessByProcId(procId));
    }

    /**
     * 新增加工技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:add')")
    @Log(title = "加工技术类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Process process)
    {
        return toAjax(processService.insertProcess(process));
    }

    /**
     * 修改加工技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:edit')")
    @Log(title = "加工技术类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Process process)
    {
        return toAjax(processService.updateProcess(process));
    }

    /**
     * 删除加工技术类
     */
    @PreAuthorize("@ss.hasPermi('wfshou:process:remove')")
    @Log(title = "加工技术类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{procIds}")
    public AjaxResult remove(@PathVariable Long[] procIds)
    {
        return toAjax(processService.deleteProcessByProcIds(procIds));
    }
}
